<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        ul {
            width: 500px;
            list-style: none;
            text-align: center;
            margin: 20px auto;
            border: 1px solid pink;
        }

        ul li {
            line-height: 30px;
            font-size: 20px;
            color: green;
        }
    </style>
</head>

<body>
    <div>
        <ul id="box">
            <li>佟湘玉</li>
            <li>白展堂</li>
            <li>吕轻侯</li>
            <li>李秀莲</li>
            <li>郭芙蓉</li>
        </ul>
        <li>666</li>
    </div>
    <script>
        // 1.
        var box = document.getElementById('box');
        var list = box.getElementsByTagName('li');
        var color = null;
        for (var i = 0; i < list.length; i++) {
            if (i % 2 === 0) {
                list[i].style.background = 'orangered';
            } else {
                list[i].style.background = 'black';
            }
            // list[i].color = list[i].style.background;
            list[i].onmouseover = function () {
                color = this.style.background;
                this.style.background = 'pink';

            }
            list[i].onmouseout = function () {
                // this.style.background = this.color;
                 this.style.background = color;
            }

        }


    </script>
</body>

</html>